package com.song.cloud.seata.service.Impl;

import com.song.cloud.seata.damain.t_order;
import com.song.cloud.seata.dao.orderDao;
import com.song.cloud.seata.service.accountService;
import com.song.cloud.seata.service.orderService;
import com.song.cloud.seata.service.storageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * @Author ZhangGuisong
 * @Date 2021/3/3-22:46
 */
@Service
@Slf4j
public class orderServiceImpl implements orderService {
    @Autowired
    private orderDao orderDao;
    @Autowired
    private storageService storageService;
    @Autowired
    private accountService accountService;
    @Override
    public void create(t_order order) {
        log.info("start create order");
        orderDao.create(order);
        log.info("create order end,ready to update decreate storage");
        storageService.decreateStorage(order.getProduct_id(),order.getCount());
        log.info(" decreate storage end,ready to decreate account");
        accountService.decreateAccont(order.getUser_id(),order.getMoney());
    }

    @Override
    public void update(Long product_id, Integer status) {

    }
}
